package org.wu.framework.inner.lazy.orm.solon.config;

import org.noear.solon.annotation.Bean;
import org.noear.solon.annotation.Condition;
import org.noear.solon.annotation.Configuration;
import org.wu.framework.lazy.orm.database.sql.expand.database.persistence.audit.Audit;
import org.wu.framework.lazy.orm.database.sql.expand.database.persistence.audit.AuditAdapter;
import org.wu.framework.lazy.orm.database.sql.expand.database.persistence.audit.lazy.LazyMysqlAudit;

import java.util.List;

/**
 * description 适配器配置bean 注入
 *
 * @author 吴佳伟
 * @date 2023/05/13 12:34
 */
@Condition(onProperty = "solon.datasource.url")
@Configuration
public class AuditSolonAutoConfiguration {

    /**
     * describe mysql sql 审计
     *
     * @return LazyMysqlAudit
     * @author Jia wei Wu
     * @date 2023/1/12 20:01
     **/
    @Bean
    @Condition(onMissingBean = LazyMysqlAudit.class)
    public LazyMysqlAudit lazyMysqlAudit() {
        return new LazyMysqlAudit();
    }
    /**
     * description:  审计适配器
     *
     * @return AuditAdapter
     * @date: 13.5.23 13:01
     */
    @Bean
    @Condition(onMissingBean = AuditAdapter.class)
    public AuditAdapter auditAdapter(List<Audit> auditList) {
//        Solon.context().getBeansOfType()
        return new AuditAdapter(auditList);
    }


}
